const { defineConfig } = require('@vue/cli-service')
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
//const path = require('path');
const THEME = process.env.VUE_APP_THEME
const TITLE = process.env.VUE_APP_TITLE
const scss_path = `@/assets/theme/${THEME}/index.scss`

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave:false,
  productionSourceMap: false,
  configureWebpack: config=>{
    config.output.filename =`js/[name].[contenthash].js`,
    config.output.chunkFilename =`js/[name].[contenthash].js`,
    config.plugins.push(new NodePolyfillPlugin())
  },
  //publicPath: './',//打包用
  publicPath: '/wap/', //H5网页用
  outputDir: 'dist',
  assetsDir: '',
  chainWebpack: config => {
    config.plugin('html')
      .tap(args => {
        args[0].title = TITLE
        return args
      })
  },
  css: {
    loaderOptions: {
      scss: {
        additionalData: `@import "${scss_path}";`
      },
    }
  },
  devServer: {
      port: 8090,
      host: '0.0.0.0',
      https: false,
      open: true,
      proxy: {
        // 可为不同的接口配置不同的代理地址
        '/wap/api': {
            // 服务地址，即你要访问的服务器地址
          target: 'https://paxgco.com/wap/',
            // 路径重写，将'/user/login'重写为'/login'
            pathRewrite: {
                '^/wap/api': ''
            },
            // 所有信息都在命令行工具打印
            logLevel: 'debug'
        },
  },
}})
